package org.example;

/**
 * @author liyuehui
 * @time 2024/6/3 19:51
 */
public class Ticket {
    private int num = 100;

    public void sale() {
        synchronized (Ticket.class) {
            if (num > 0)
                System.out.println(Thread.currentThread().getName() + "卖出一张票，剩余：" + (--num));
        }
    }

    public int getNum() {
        return num;
    }
}
